

class Result {
	public static int MAX_MOVES = 40;

	public static int random = 0;

	public boolean player;
	public byte color;
	public int x;
	public int y;
	public int moves;
	public int count;
	public int point;
	public int capture;
	public int weight;

	public byte moves_x[];
	public byte moves_y[];
	public byte moves_moves[];
	public byte moves_count[];
	public byte moves_point[];
	public int moves_capture[];
	public int moves_weight[];
	//public int min_count;
	public int max_count;
	public int min_weight;
	public int max_weight;

	public Result(boolean p,byte c) {
		int i;
		player = p;
		color = player? c : (c==Othello.BLACK? Othello.WHITE : Othello.BLACK);
		x = -1;
		y = -1;
		moves = 0;
		count = 0;
		point = 0;
		capture = 0;
		weight = 0;
		moves_x = new byte[MAX_MOVES];
		moves_y = new byte[MAX_MOVES];
		moves_moves = new byte[MAX_MOVES];
		moves_count = new byte[MAX_MOVES];
		moves_point = new byte[MAX_MOVES];
		moves_capture = new int[MAX_MOVES];
		moves_weight = new int[MAX_MOVES];
		for(i=0; i<MAX_MOVES; i++) {
			moves_x[i] = -1;
			moves_y[i] = -1;
			moves_moves[i] = 0;
			moves_count[i] = 0;
			moves_point[i] = 0;
			moves_capture[i] = 0;
			moves_weight[i] = 0;
		}
		resetWeight();
	}

	public void addMove(int x,int y) {
		moves_x[moves] = (byte)x;
		moves_y[moves] = (byte)y;
		moves_count[moves] = (byte)count;
		moves_point[moves] = (byte)point;
		moves_capture[moves] = capture;
		moves++;
	}

	public void resetCount() {
		moves = 0;
		//min_count = -1;
		max_count = -1;
	}

	public void setMoves(int m,int n) { moves_moves[m] = (byte)n; }

	public void setCount(int m,int c) {
		//Othello.println("setCount(move="+move+",count="+count+",min_count="+min_count+",max_count="+max_count+")");
		if(moves<=m) moves = m+1;
		moves_count[m] = (byte)c;
		/*if(min_count==-1 || c<moves_count[min_count] || (c==moves_cont[min_count] &&
			(player? moves_moves[min_count]<moves_moves[m] :
				moves_moves[min_count]>moves_moves[m]))) min_count = m;*/
		if(max_count==-1 || c>moves_count[max_count] || (c==moves_count[max_count] &&
			(player? moves_moves[max_count]<moves_moves[m] :
				moves_moves[max_count]>moves_moves[m]))) max_count = m;
	}

	public void setMaxCount() {
		if(max_count==-1) return;
		x = moves_x[max_count];
		y = moves_y[max_count];
		count = moves_count[max_count];
	}

	public void setAverageCount() {
		if(moves==0) return;
		x = moves_x[max_count];
		y = moves_y[max_count];
		count = 0;
		for(int i=0; i<moves; i++) count += moves_count[i];
		count /= moves;
	}

	public void resetWeight() {
		moves = 0;
		weight = 0;
		min_weight = -1;
		max_weight = -1;
	}

	public void setWeight(int m,int w) {
		if(moves<=m) moves = m+1;
		moves_weight[m] = w;
		if(min_weight==-1 || w<moves_weight[min_weight] || (w==moves_weight[min_weight] &&
			(player? moves_moves[min_weight]<moves_moves[m] :
				moves_moves[min_weight]>moves_moves[m]))) min_weight = m;
		if(max_weight==-1 || w>moves_weight[max_weight] || (w==moves_weight[max_weight] &&
			(player? moves_moves[max_weight]<moves_moves[m] :
				moves_moves[max_weight]>moves_moves[m]))) max_weight = m;
	}

	public void setMaxWeight() {
		if(max_weight==-1) return;
		x = moves_x[max_weight];
		y = moves_y[max_weight];
		weight = moves_weight[max_weight];
	}

	public void setMinMaxWeight() {
		if(max_weight==-1) return;
		x = moves_x[max_weight];
		y = moves_y[max_weight];
		weight = (moves_weight[min_weight]+moves_weight[max_weight])/2;
	}

	public void setAverageWeight() {
		if(max_weight==-1) return;
		x = moves_x[max_weight];
		y = moves_y[max_weight];
		weight = 0;
		for(int i=0; i<moves; i++) weight += moves_weight[i];
		weight /= moves;
	}
}



